<script setup>
/**
 * @param libs
 */
import { onLoad } from '@dcloudio/uni-app'

/**
 * @import components
 */
import topPlaceholder from '@/components/indexComp/topPlaceholder.vue';
import topTabBar from '@/components/indexComp/topTabBar.vue';
import buttomBar from '@/components/commons/buttomBar.vue';
import FloatingPublishButton from '@/components/indexComp/FloatingPublishButton.vue';
import indexCenter from '@/components/indexComp/indexCenter.vue';

/**
 * @import libs
 */
import { storeToRefs } from 'pinia'

//pinia -> useHomePageStore
import { useHomePageStore } from '@/stores/index/homePage'

/**
 * @param selectedTopBarIndex 主页顶部导航栏下标
 */
let { selectedTopBarIndex } = storeToRefs(useHomePageStore())

/**
 * 进入页面生命周期
 */
onLoad(() => {
	//从缓存中拿isLogin
	const isLogin = uni.getStorageSync('isLogin')
	
	if (!isLogin) {
		const path = "/pages/login/index"
		uni.redirectTo({ url: path })
	}
})

</script>
<template>
	<div class="app">
		<topPlaceholder></topPlaceholder>
		<topTabBar></topTabBar>
		<indexCenter></indexCenter>
		<buttomBar></buttomBar>
		<FloatingPublishButton v-show="selectedTopBarIndex === 0"></FloatingPublishButton>
	</div>
</template>
<style scoped>
.app {
	width: 750rpx;
	height: 100vh;
	background-color: #ffefe1;
}
</style>